#include "ProgramState.h"
#include "../multimedia/SoundManager/SoundManager/include/SoundManager.h"
#include "../shared/shared_types.h"
#include <string>
const std::string MUSIC_PATH = "../multimedia/SoundManager/SoundManager/sound/";
const std::string SOUND_PATH = "../multimedia/SoundManager/SoundManager/sound/";

namespace Putin{

        bool ProgramState::setMusic(std::string filename)
        {
                SoundManager* snd = SoundManager::instancePtr();
                // set sound manager music
                snd->loadMusic( (MUSIC_PATH + filename).c_str(),true);
                
                return true;
        }

        bool ProgramState::playMusic()
        {
                SoundManager::instance().playMusic();

                return true;
        }

        void ProgramState::stopMusic()
        {
                SoundManager::instance().stopMusic();
        }

        bool ProgramState::loadSound(std::string filename)
        {
                SoundManager& snd = SoundManager::instance();
                unsigned int audio = snd.loadSound((SOUND_PATH + filename).c_str());
                mAudio[filename] = audio;
                return true;
        }

        void ProgramState::unloadAudios()
        {
                SoundManager& snd = SoundManager::instance();
                snd.deleteBuffers();
                mAudio.clear();
        }

        unsigned int ProgramState::getSoundBuffer(std::string filename)
        {
                return mAudio[filename];
        }

        void ProgramState::playSound(std::string id, Vec3f& pos, Vec3f& vel, const char* cullType)
        {
                SoundManager& snd = SoundManager::instance();
                SoundBuffer buff = mAudio[id];
                snd.playSound(buff, 1,cullType, pos.v,vel.v, NORMAL_SOUND);
        }
}